﻿<%@ Page Title="店铺档案" Language="C#" MasterPageFile="~/master/m.master" %>
<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../assets/css/plugins/footable/footable.core.css" rel="stylesheet">
<link href="../assets/css/shelf/base.css" rel="stylesheet">
<style type="text/css">
.system-box .right-side{width: 100%;}
.condition, .condition-title{position: relative; border-bottom: 1px solid #dfdfdd;}
.condition .form-control{padding: 2px 6px;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
<div class="system-box">
	<div class="right-side">
		<div class="btns-container"></div>
		<div class="condition">
			<label>条件</label>
			<input type="text" class="form-control input-w160" id="search-keys" placeholder="搜索日志内容" />
			<label>时间范围</label>
            <input type="text" class="form-control layer-date" 
            	readonly="readonly" placeholder="开始时间" id="search-start" />
			<label class="to">到</label>
			<input type="text" class="form-control layer-date" 
				readonly="readonly" placeholder="结束时间" id="search-end" />
		</div>
		
		<div class="right-content-box">
			<div class="ibox-content">
				<table class="footable table table-stripped table-list">
				    <thead>
	                    <tr>
	                        <th>编号
	                        </th>
	                        <th>日志内容</th>
	                        <th>操作时间</th>
	                        <th>操作对象</th>
	                        <th>访问者IP</th>
	                        <th>操作员</th>
	                    </tr>
	                </thead>
					<tbody id="pageList"></tbody>
				</table>
			</div>
		</div>
		<div class="pageControl"></div>
	</div>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" Runat="Server">
<script src="../assets/js/plugins/layer/laydate/laydate.js"></script>
<script src="../assets/js/page/pageControl.js"></script>
<script src="../assets/js/page/rScroll.js"></script>
<script src="../assets/js/page/tableControl.js"></script>
<script type="text/html" id="tpl-log-item">
    {{# for(var i = 0, len = d.length; i < len; i++){ }}
    <tr {{# if(i%2 == 0){ }} class="gradeX footable-even"
		{{# }else{ }} class="gradeX footable-odd" {{# } }}>
        <td>{{d[i].ID}}
        </td>
        <td>{{d[i].LogContent}}
        </td>
        <td>{{d[i].CreateTime.replace('T',' ').substring(0,16)}}
        </td>
        <td>{{d[i].Action}}
        </td>
        <td>{{d[i].HostAddress}}
        </td>
        <td>{{d[i].Operator}}
        </td>
    </tr>
    {{# } }}
</script>
<script type="application/javascript">
$('document').ready(function(){
	//模块ID
    var ModuleID = Y.getUrlParam("ModuleID");
    //当前页数
    var page = 1;
//  var maxYear = '';
	//获取按钮
	commonUtil.loadBtnList(ModuleID,function(){
		rScroll();
	});
	//初始化日期控件
	$('#search-start').val(new Date().getFullYear() + '-01-01');
	$('#search-end').val(new Date().getFullYear() + '-12-31');
	var searchstart = {
		elem: "#search-start",
		format: "YYYY-MM-DD",
		min: "2015-12-01",
		max: "2099-12-01",
		istime: false,
		istoday: false,
		choose: function (datas) {
			searchend.min = datas;
			searchend.start = datas
        }
    };
    var searchend = {
        elem: "#search-end",
        format: "YYYY-MM-DD",
        min: "2015-12-01",
        max: "2099-12-01",
        istime: false,
        istoday: false,
        choose: function (datas) {
            searchstart.max = datas
        }
    };
    laydate(searchstart);
    laydate(searchend);
	
	//绑定年份
	var gfy = new Date().getFullYear();
	for(var i = gfy; i < gfy + 10; i++){
		$('#Year').append('<option value="'+ i +'">'+ i +'</option>');	
	}
    
    var loadList = function(){
    	var keys = $('#search-keys').val().trim().replace(/'/g, '');
    	pageControl.init('Common', 'GetLog', {
            BeginDate: $('#search-start').val(),
            EndDate: $('#search-end').val(),
            Keys: keys,
            Page: page,
            Size: 100,
            needLayer: true,
            alwaysCallBack: function () {
                $('#pageList').empty();
            }
        }, function (result) {
            page = result.page;
            var tBody = [];
            if (!Y.checkNull(result)) {
                if (result.data.Items.length == 0) {
                    Y.NoData(body, 5);
                    return false;
                }
                var pl = document.getElementById('tpl-log-item').innerHTML;
                laytpl(pl).render(result.data.Items, function (html) {
                    document.getElementById('pageList').innerHTML = html;
                });
                rScroll();
            }
        });
    }
    loadList();
    
    $('.btns-container').on('click','#btn-search',function(){
    	loadList();
    })
})
</script>
</asp:Content>

